# -*- coding: utf-8 -*-

import gobject
import gtk, gtk.glade
import gconf, gnomevfs, gnome

gconf_keys = {	'library' : '/apps/rhythmbox/plugins/videosource/library',
	     }

class VideoSourceConfigDlg (object):
	def __init__(self, glade_file):
		self.gconf = gconf.client_get_default()
		gladexml = gtk.glade.XML(glade_file)

		self.dialog = gladexml.get_widget('preferences_dialog')
		self.file_path_entry = gladexml.get_widget('file_path_entry')
		library_folder = self.gconf.get_string(gconf_keys['library'])
		if not library_folder:
			library_folder = "/tmp/"
		self.file_path_entry.set_current_folder(library_folder)
		self.dialog.connect("response", self.dialog_response)
		self.file_path_entry.connect("selection-changed", self.library_changed)

	def get_dialog (self):
		return self.dialog

	def dialog_response (self, dialog, response):
		dialog.hide()

	def library_changed (self, button):
		library_folder = self.file_path_entry.get_current_folder()
		self.gconf.set_string(gconf_keys['library'], library_folder)
		print library_folder
